import widgetText from '../widget/texts/widgetText/config'
import widgetNum from '../widget/texts/widgetNum/config'
import widgetDate from '../widget/texts/widgetDate/config'
import widgetButton from '../widget/texts/widgetButton/config'
import widgetImage from '../widget/texts/widgetImage/config'
import widgetVideo from '../widget/texts/widgetVideo/config'

import scrollTable from '../widget/table/scrollTable/config'
import widgetTab from '../widget/texts/widgetTab/config'

import border01 from '../widget/border/border01/config'
import border02 from '../widget/border/border02/config'
import border03 from '../widget/border/border03/config'
import border04 from '../widget/border/border04/config'
import border05 from '../widget/border/border05/config'
import border06 from '../widget/border/border06/config'
import border07 from '../widget/border/border07/config'
import border08 from '../widget/border/border08/config'
import border09 from '../widget/border/border09/config'
import border10 from '../widget/border/border10/config'
import border11 from '../widget/border/border11/config'
import border12 from '../widget/border/border12/config'
import border13 from '../widget/border/border13/config'

import bars from '../widget/chart/bars/configs'
import lines from '../widget/chart/lines/configs'
import pies from '../widget/chart/pies/configs'
import gauges from '../widget/chart/gauge/configs'
import radar from '../widget/chart/radar/configs'
import map from '../widget/chart/map/configs'

export const options = [
  {name: '信息', key: 'info', icon: 'icon-txt', children: [
      widgetText,
      widgetNum,
      widgetDate,
      widgetButton,
      widgetImage,
      widgetVideo,
      scrollTable,
      widgetTab
    ]
  },
  {
    name: '装饰', key: 'decoration', icon: 'icon-txt', children: [
      border01,
      border02,
      border03,
      border04,
      border05,
      border06,
      border07,
      border08,
      border09,
      border10,
      border11,
      border12,
      border13
    ]
  },
  {name: '图表', key: 'chart', icon: 'icon-board', children: [
      ...bars,
      ...lines,
      ...pies,
      ...gauges,
      ...radar,
      ...map
    ]
  },
  {name: '列表', key: 'list', icon: 'icon-list3'},
  {name: '控件', key: 'input', icon: 'icon-setting'}
]

export function getConfigByCptKey(cptKey) {
  let config = null
  for(let i=0,len= options.length; i<len; i++) {
    if(config) {
      break
    }
    if(options[i].children) {
      config =  options[i].children.find(o => o.cptKey === cptKey)
    }
  }

  return JSON.parse(JSON.stringify(config))
}
